package edu.tyut.game.controller.feedback;

import edu.tyut.game.config.SocketConfig;
import edu.tyut.game.model.Feedback;
import edu.tyut.game.model.Result;
import edu.tyut.game.service.FeedbackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;

@Slf4j
@RestController
@RequestMapping("/feedback")
public class FeedbackController {
    private FeedbackService feedbackService;
    @Autowired
    public void setFeedbackService(FeedbackService feedbackService) {
        this.feedbackService = feedbackService;
    }

    @PostMapping("/sendFeedback")
    public Result<String> sendFeedback(@RequestBody Feedback feedback){
        feedbackService.addFeedback(feedback);
        return Result.success("成功", "成功");
    }

    private SocketConfig socketConfig;
    @Autowired
    public void setSocketConfig(SocketConfig socketConfig) {
        this.socketConfig = socketConfig;
        // 只能调用一次
        socketConfig.getSocket();
    }

    @GetMapping("/hello")
    public String hello(){
        socketConfig.writeInfo("Hello World Socket");
        return "Hello 世界!";
    }
}
/*
flyGame uid 局数 输赢(0,1) 时间戳
PoemRecommend uid poemId 1
 */
